Ext.onReady(function () {
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
    var columns = [
	    { id: 'name', header: 'Name', dataIndex: 'name__c', width: 100, type: 'string' },	    
        { header: 'Active', dataIndex: 'active', type: 'boolean' },
	    { header: 'Start Date', dataIndex: 'startdate', xtype: 'datecolumn' },
	    { header: 'End Date', dataIndex: 'enddate', xtype: 'datecolumn' },
        { header: 'Product', dataIndex: 'product__c', type: 'combo' },
	    { header: 'Description', dataIndex: 'desc', width: 220, type: 'string' }
	];
    var recordType = [
        { name: 'id__c', mapping: 'id__c', type: 'int' },
        { name: 'name__c', mapping: 'name__c', type: 'string' },
        { name: 'active', mapping: 'active', type: 'boolean' },
        { name: 'startdate', mapping: 'startdate', type: 'date' },
        { name: 'enddate', mapping: 'enddate', type: 'date' },
        { name: 'product__c', mapping: 'product__c.display', type: 'string' },
        { name: 'desc', mapping: 'desc', type: 'string' },
        { name: 'objecttype', mapping: 'objecttype', type: 'string' }
    ];
    api = {
        read: 'Team.aspx?action=read',
        create: 'Team.aspx?action=create',
        update: 'Team.aspx?action=update',
        destroy: {
            url: 'Team.aspx?action=destroy',
            method: "DELETE"
        }
    };
    var formConfig = { title: 'New Team',
        items: [{ fieldLabel: 'Name', name: 'name', allowBlank: false },
            { fieldLabel: 'Prefix', name: 'last' },
            { fieldLabel: 'Active', name: 'active' },
            { fieldLabel: 'StartDate', name: 'startDate' },
            { fieldLabel: 'EndDate', name: 'endDate' },
            { fieldLabel: 'Description', name: 'desc', vtype: 'email' },
            { fieldLabel: 'Time', name: 'time', minValue: '8:00am', maxValue: '6:00pm' }
        ]
    }
    var gridPanel = new ScrumEditorGridPanel({ id: 'grid-panel',
        storeConfig: { proxyConfig: {api: api }, readerConfig: { recordType: recordType }, writerConfig: { api: api} },
        cmConfig: { columns: columns },
        newPwConfig: { url: 'save-form.php', formConfig: formConfig }
        //renderTo:'datagrid'
    });

    var viewport = new DefaultScrumViewport({
        center: { title: 'Team List', gridPanel: gridPanel }
    });
});
